define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user.order/index',
        add_url: 'user.order/add',
        edit_url: 'user.order/edit',
        delete_url: 'user.order/delete',
        export_url: 'user.order/export',
        modify_url: 'user.order/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: '订单id',search: false},
                    {field: 'order_no', title: '订单号'},
                    {field: 'goods_name', title: '商品id',search: false},
                    {field: 'schedule', title: '场次id',search: false},
                    {field: 'g_price', title: '商品价格',search: false},
                    {field: 'buy', title: '买方',search: false},
                    {field: 'sale', title: '卖方',search: false},
                    {field: 'pay_method', title: '支付方式',
                        templet: function(d){
                            if(d.pay_method == 1){return "微信"}
                            if(d.pay_method == 2){return "支付宝"}
                            if(d.pay_method == 3){return "线下银行卡"}
                            if(d.pay_method == 0){return "未设置"}
                        }
                    },
                    {field: 'real_price', title: '真实付款价格',search: false},
                    {field: 'pay_state', title: '支付状态',search: 'select',selectList: {
                        0: '提交订单待支付',
                        '-1': '付款失败（取消）',
                        1: '成功付款'
                    },
                        templet: function(d){
                            if(d.pay_state == 0){return "提交订单待支付"}
                            if(d.pay_state == -1){return "付款失败（取消）"}
                            if(d.pay_state == 1){return "成功付款"}
                        }
                    },
                    {field: 'state', title: '订单状态',search: 'select',selectList: {
                        '-1': '删除',
                        1: '正常显示'
                    },
                        templet: function(d){
                            if(d.state == -1){return "删除"}
                            if(d.state == 1){return "正常显示"}
                        }
                    },
                    {field: 'create_time', title: '创建时间',search: false},
                    {field: 'dispute', title: '投诉详情',search: false},
                    // {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});